if/else

if/else

構造

if condition

then

statements

[elif condition

then

statements ...........]

[else

statements]

fi

if 条件が真(true)の場合then以下をstatementsを実行する。 もしくは、正常終了した。

else 条件が偽(false)の場合statementsを実行する。もしくは、異常終了した。

elif else ifの略条件が偽(false)の場合次の条件を判定真の場合statementsを実行する。もしくは、正常終了した。

fi 条件式の終了を示している

return

構造

return [n-statements]

終了ステータスとして、nを返す。

終了ステータスの組み合わせ

if statements1 && statements2

then

statements

fi

if statements1|| statements2

then

statements

fi

&&
||
statements1 statements2   statements1 statements2  
×
×
×
×
×
×
×

○真 ×偽 ‐未実効

終了ステータス 規定

通常は、

0 = 正常終了

0 != 異常終了(1から255)

例外)

diff 差分がない=0 差分がある=1 ファイルがないなどのERR=2

Last edit was Monday, 06/17/2002 <back> <top>

テレワークならECナビ Yahoo 楽天 LINEがデータ消費ゼロで月額500円〜!
無料ホームページ 無料のクレジットカード 海外格安航空券 海外旅行保険が無料! 海外ホテル